package com.hzy.quetosys.interceptor;

import com.hzy.quetosys.entity.User;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


public class LoginInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response,Object handle)throws Exception{
        HttpSession session=request.getSession();
User user=(User)session.getAttribute("user");

if (user!=null){
    return true;
}
response.sendRedirect("/login");
        return false;
    }


}
